package org.example.observe.controller;

import org.example.observe.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/observe")
public class ObserveController{

    @Autowired
    private OrderService orderService;

    /**
     * 工厂 + 观察者模式
     *
     * @param orderNo : 订单号，模拟支付回调成功
     * @return
     */
    @GetMapping
    public String observe(@RequestParam String orderNo) {
        return orderService.paySuccess(orderNo);
    }

}
